 require 'rextral.rb'
 require 'relation_dsl.rb'

 destination_connection = Connection.global_connection("localhost","root","","railscountry_development","mysql")
 source_connection = Connection.global_connection("localhost","root","","summer_development","mysql")


  #~ #This is a profiling functionality where you can see profiles for different tables under same/different databases.
      #~ (Profile.table_is_questions).under source_connection
      #~ Profile.connection_is source_connection
      #~ Profile.generate_profile_for_databases [source_connection,destination_connection]  
      #~ Profile.generate_profile_for_tables(
      #~ {
              #~ ["answers"]=>source_connection,
              #~ ["questions"]=>source_connection,
              #~ ["users"]=>source_connection
      #~ })
      #~ (Profile::Rule.rules_for_first_1_column_of_questions).under source_connection
      #~ Profile::Rule.profile_single_column("user_id","questions",source_connection)
      #~ Profile::Rule.tabulate_possible_rules(
        #~ {
              #~ :mode=>"single",
              #~ ["table_one","table_two"]=>connection
        #~ })  
      #~ Profile::Rule.tabulate_possible_rules(
        #~ {
              #~ :mode=>"multiple",
              #~ ["column_one","column_two"]=>["tablename","connection"],
              #~ ["column_one","column_two"]=>["tablename","connection"],
              #~ ["column_one","column_two"]=>["tablename","connection"]
        #~ })
                




  # The DSL for difference between databases, tables under same database, tables under different database.
  # This can be used for matching source and destination databases.
  #~ Difference.check_compatibility_for_answers_and_teachers_under destination_connection
  #SOME BUG WHILE SHOWING THE COLUMNS
          #~ Difference.check_compatibility("answers",source_connection,"",destination_connection)  
          #~ Difference.check_complete_db_compatibility(source_connection,destination_connection)
  #~ (Normalize::Splitter.split_questions_horizontally_at_3).under source_connection 
  #~ Normalize::Splitter.split_tables(
  #~ {
      #~ ["answers_at_3","users_at_1"]=>source_connection
  #~ })




  # The extraction formats through DSL
  #~ Extraction.all_tables_from source_connection
  #~ (Extraction.extract [2,5,6]).from source_connection
  #~ (Extraction.extract "first_2_table").from source_connection
  #~ (Extraction.extract "last_1_table").from source_connection
  #~ Extraction.extract_to_csv(source_connection,
	#~ {
		#~ :table_names=>:all
	#~ })	
  #~ Extraction.extract_to_csv(source_connection,
	#~ {
		#~ :table_names=>["questions","answers"] 
	#~ })




  #Loading formats through DSL
  #~ Loading.load_to_database(destination_connection,'', 
  #~ {
          #~ :from_file=>true,
          #~ :table_names=>"D:\\MyData\\Summer_of_Code"
  #~ })	
  #~ Loading.db_to_db_load(source_connection,destination_connection,
 	#~ {
		#~ :table_names => ["questions"]
	#~ })
  #~ ((Loading.load "first_2_tables").from source_connection).to destination_connection

  #~ ((Loading.load [3,5]).from source_connection).to destination_connection 

  #~ ((Loading::Constraint.load_first_3_columns_from_tablename).under source_connection).to destination_connection
  # SOME BUG HERE WHILE LOADING
          #~ Loading::Constraint.load_selected_columns(
          #~ {
                      #~ {:questions=>[source_connection,"user_id","created_at"]}=>destination_connection
          #~ })
  #~ Loading::Constraint.load_auto_increment_columns(
  #~ {
        #~ {:questions=>[source_connection]}=>destination_connection
  #~ })




  #~ RELATION TRANSFORMS: This is being used for transforming the relationships between different tables.  
  #~ Relation.many_to_many(
    #~ {   
          #~ :parent_connection=>source_connection,
          #~ :child_connection=>destination_connection,
          #~ ["questions","id",source_connection]=>["answers","id",destination_connection]
    #~ })
  #~ Relation.one_to_many(
    #~ {
          #~ :parent_table=>"answers with id",
          #~ :parent_connection=>destination_connection,
          #~ :child_connection=>source_connection,
          #~ :child_tables=>[["questions"]]
    #~ })  
  


  
  #~ CONSTRAINT TRANSFORMS: Currently only not null,unique,auto_increment and primary key constraints are supported.
  #~ (Constraint.make_last_name_under_students_as_not_null).with destination_connection
  #~ (Constraint.undo_last_name_under_students_as_not_null).with destination_connection
  #~ (Constraint.make_last_2_columns_under_teachers_as_not_null).with destination_connection    
  #~ Constraint.drop_constraint(
      #~ {
        #~ :connection=>destination_connection,
        #~ :not_null=>{:students=>[4,2],:teachers=>[2]},
        #~ :primary_key=>{:teachers=>[1]}
     #~ })  
  #~ Constraint.create_constraint(
    #~ {
        #~ :connection=>destination_connection,
        #~ :not_null=>{:table_one=>[1,2],:table_two=>[3,5]},
        #~ :primary_key=>{:table_name=>[5]}
    #~ })
  
  
  
  
  
  # COLUMN TRANSFORMS
  #~ #This is the two dimensional array which user has to build
  #~ @table = 'some_table'
  #~ all_string=[['1','2','rename'],['3','4','resize']]
  #~ all_string.each {|old_name,new_name,trans_option|
       #~ Transform.+"#{trans_option}_"+"#{old_name}"+"_under_"+"#{@table}"+"_to_"+"#{new_name}"
  #~ }	
  #~ # This is a dynamic column transformer.
  #~ ColumnTransform.last_name_under_students_rename_as_whatever_resize_to_45_datatype_as_int destination_connection
  # This is a multi transform for a single column.
  #~ ColumnTransform.many_transforms(
       #~ {
            #~ :connection=>destination_connection,
            #~ :table_name=>'students',
            #~ :col_name=>'first_name',
            #~ :rename_to=>'company_name',
            #~ :resize_to=>250,
	#~ })




  # NORMALIZATION TRANSFORMS 
  #~ Example by absolute
        #~ Here you can specify child table columns in all formats specified above	
        #~ Normalize.students_to_first_form_with_primary_as_id(
        #~ {
                #~ :column_selection=>'absolute',
                #~ :connection=>destination_connection,
                #~ :second_table_new=>["last_Name","first_Name","division"],
                #~ :third_table_new=>["id"]
        #~ })
  #Example by numeric				
      # Here you can specify child table columns in all formats specified above	
      #~ Normalize.students_to_first_form_with_primary_as_id(
      #~ {
                #~ :column_selection=>'numeric',
                #~ :connection=>destination_connection,
                #~ :second_table_new=>[3,4],
                #~ :third_table_new=>[1]
      #~ })
  #Example by relative				
      # Here you can specify child table columns in all formats specified above	
      #~ Normalize.students_to_first_form_with_primary_as_id(
      #~ {
                #~ :column_selection=>'relative',
                #~ :connection=>destination_connection,
                #~ :second_table_new=>"first_1_column",
                #~ :third_table_new=>"last_2_columns",
      #~ })
  #Example for hybrid:			
      #Here you can specify child table columns in all formats specified above
      #~ Normalize.students_to_first_form_with_primary_as_id(
      #~ {
                #~ :column_selection=>'hybrid',
                #~ :connection=>destination_connection,
                #~ :second_table_new=>[1,2],
                #~ :third_table_new=>"last_2_column",
                #~ :fourth_table_new=>["last_Name","division"]
      #~ })
	
